<include file="Public:header" />
<link rel="stylesheet" type="text/css" href="/Plugin/uploader/webuploader.css">
<link rel="stylesheet" type="text/css" href="/Plugin/uploader/style.css" />
{:W('Navigation')}
<div class="body-right">
	<div class="row-table">
		<div class="row-table-title">添加员工</div>
		<div class="row-table-body">
			<form class="form-horizontal " action="{:U('core/user/addUser')}" method="post" enctype="multipart/form-data">
				<input type="hidden" name="navigation_id" value="{$navigation.navigation_id}"/>
				<p class="form-title">添加员工&nbsp;&nbsp;<a href="javascript:history.go(-1);">返回</a></p>
				<div class="form-group">
					<label for="name" class="col-sm-2 control-label"></label>
					<div class="col-sm-3">
						<label class="checkbox-inline"><input type="radio" id="add" name="radio_type" value="add" checked="checked" >快捷添加</label>
						<label class="checkbox-inline"><input type="radio" id="email" name="radio_type" value="email" >邮箱邀请</label>
					</div>
				</div>
				<div class="form-group">
					<label for="name" class="col-sm-2 control-label">用户名</label>
					<div class="col-sm-3">
						<input id="inname" class="form-control" type="text" name="name" onchange="che(this.id)"><span class="color-red">*唯一</span>
					</div>
				</div>
				<div class="form-group">
					<label for="name" class="col-sm-2 control-label">姓　名</label>
					<div class="col-sm-3">
						<input class="form-control" type="text" name="nickname" id="nickname" onchange="che(this.id)"><span class="color-red">*</span>
					</div>
				</div>
				<div class="form-group" id="password">
					<label for="name" class="col-sm-2 control-label">密码</label>
					<div class="col-sm-3">
						<input class="form-control" type="text" name="password" value="123456"><span class="color-red">*</span>
					</div>
				</div>
				<div class="form-group">
					<label for="email" class="col-sm-2 control-label">邮箱</label>
					<div class="col-sm-3">
						<input class="form-control" type="text" name="email" value="<php>echo $_SESSION['user_id'].'_'.time();</php>@dgpaotui.com"><span class="color-red">*</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">手机</label>
					<div class="col-sm-3">
						<input class="form-control" name="telephone" type="text" value="">
					</div>
				</div>
				<div class="form-group">
					<label for="name" class="col-sm-2 control-label">用户类别</label>
					<div class="col-sm-3">
						<select class="form-control" name="category_id">
							<option value="">请选择类别</option>
							<if condition="session('?admin')">
								<option value="1">管理员</option>
							</if>
							<option value="2">员工</option>
						</select><span class="color-red">*</span>
					</div>
				</div>
				<div class="form-group">
					<label for="name" class="col-sm-2 control-label">员工类型</label>
					<div class="col-sm-3">
						<select  name="type" class="form-control" >
							<volist name="type" id="vo">
							<option value="{$key}" <if condition="$user['type'] == $key">selected = "selected"</if>>{$vo}</option>
							</volist>
						</select>
					</div>
				</div>
				<div class="form-group department">
					<label for="name" id="department" class="col-sm-2 control-label">部门</label>
					<div class="col-sm-3 dep1 dli">
						<select id="1" <if condition="session('?admin')">name="department_id"</if> class="form-control" onchange="changeRoleContent(this.value,this.id)">
							<option value="">请选择部门</option>
							<volist name="department_list" id="temp">
								<option value="{$temp.department_id}">{$temp.name}</option>
							</volist>
						</select>
						<if condition="!session('?admin')">
							<input id="departments" name="department_id" type="hidden" value="" />
						</if>
					</div>

				</div>
				<div class="form-group">
					<label for="name"  class="col-sm-2 control-label">岗位</label>
					<div class="col-sm-3">
						<if condition="session('?admin')">
						<select id="position" name="position_id" class="form-control">
							<volist name="allpositions" id="vos">
								<option value="{$vos.position_id}">{$vos.name}</option>
							</volist>
						</select>
						<else />
						<select id="position" name="position_id" class="form-control">
							<volist name="zz_un" id="zz">
								<option value="{$zz.position_id}">{$zz.name}</option>
							</volist>
						</select>
						</if>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">员工配备</label>
					<div class="col-sm-8">
						<label class="checkbox-inline">
					      <input name="peibei[]" type="checkbox" value="1"> 箱子
					  	</label>
					   	<label class="checkbox-inline">
					      <input name="peibei[]" type="checkbox" value="2">  腰包
					   	</label>
					   	<label class="checkbox-inline">
					      <input name="peibei[]" type="checkbox" value="3"> 工服
					   	</label>
					   	<label class="checkbox-inline">
					      <input name="peibei[]" type="checkbox" value="4"> 工牌
					   	</label>
					   	<label class="checkbox-inline">
					      <input name="peibei[]" type="checkbox" value="5"> 雨衣
					   	</label>
					   	<label class="checkbox-inline">
					      <input name="peibei[]" type="checkbox" value="6"> Polo衫
					   	</label>
					   	<label class="checkbox-inline">
					      <input name="peibei[]" type="checkbox" value="7"> 头盔
					   	</label>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">是否买保险</label>
					<div class="col-sm-4">
						<label class="checkbox-inline">
					      <input name="baoxian" type="radio" value="0" checked> 未买
					  	</label>
					  	<label class="checkbox-inline">
					      <input name="baoxian" type="radio" value="1"> 已买
					  	</label>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">工资银行卡号</label>
					<div class="col-sm-4">
						<input name="bankcard" class="form-control" placeholder="银行卡号，如：6222******">
					</div><span class="col-sm-3">默认建设银行</span>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">身份证</label>
						<div class="col-sm-4">
						<input name="sfzid" class="form-control" placeholder="请填写身份证号码！">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">身份证图片上传</label>
					<div class="col-sm-4">
				        <label class="sr-only" for="inputfile">文件输入</label><input id="img_up" class="btn btn-info" type='file' name="img_up[]">
					</div>
       			</div>
       			<div class="form-group">
					<label class="col-sm-2 control-label">头像图片上传</label>
					<div class="col-sm-4">
				        <label class="sr-only" for="inputfile">文件输入</label><input id="img_up" class="btn btn-info" type='file' name="img_up[]">
					</div>
       			</div>
       			<div class="form-group" id="upload_file">
					<label class="col-sm-2 control-label">其它图片</label>
					<div class="col-sm-4">
				        <label class="sr-only" for="inputfile">文件输入</label><input id="img_up" class="btn btn-info" type='file' name="img_up[]">
				        <input type="button" class="btn btn-primary btn-xs"  id="addcontractType" value="增加" />
					</div>
       			</div>
				<div class="form-group">
					<label class="col-sm-2 control-label"></label>
					<div class="col-sm-3">
						<input name="submit" class="btn btn-primary" type="submit" value="添加"/>&nbsp;&nbsp;
						<input type="button" class="btn" value="取消" onclick="javascript:history.go(-1);"/>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>
<div class="clear"></div>

<script type="text/javascript">
	var gdid=1;
	$(function(){
		$('#addcontractType').click(function(){
		$(this).after('<input id="img_up" name="img_up[]" class="btn btn-info" type="file" /><input type="button" class="btn btn-xs deletecontractType" value="[删除]" />');
	});
	$('#upload_file').on('click','.deletecontractType',function(){
		$(this).prev().remove();
		$(this).remove();
	});
		
		va = $('input[name="radio_type"]:checked').val();
		if( va == 'email'){$('#password').hide();}else{$('#password').show();}
		$('#email').click(
			function(){
				$('#password').hide();
			}
		);
		$('#add').click(
			function(){
				$('#password').show();
			}
		);
	});
	function changeRoleContent(department_id,gdid){
		if(department_id == ''){
			$(".department").append('');
		}else{
			
			<if condition="!session('?admin')">
			gdid=parseInt(gdid);
			chk3=$(".dep3 select").attr('id');
			chk2=$('.dep2 select').attr('id');
			if(chk3 && gdid==1){
				$(".dep3").remove();
			}
			gdid++;
			$(".dep"+gdid).remove();
				

			//获得下级目录
			getJson('{:U("hrm/Structure/getDeson","id=")}',department_id,'.department',gdid);
			$('#departments').val(department_id);
			<else />

			//获得部门权限
//			$.ajax({
//				type:'get',
//				url:'{:U("hrm/Structure/getDepartmentPosition","id=")}'+department_id,
//				async:false,
//				success:function(data){
//					if(data){
//						options = '';
//						$.each(data, function(k, v){
//							options += '<option value="'+v.position_id+'">'+v.name+'</option>';
//						});
//						$("#position").html(options);
//					}else{
//						$("#position").html('');
//					}
//				},
//				dataType:'json'
//			});	
			</if>
			
		}
		

	}
	function getJson(urls,department_id,ddiv,gdid){
		$.ajax({
			type:'get',
			url:urls+department_id,
			async:false,
			success:function(data){
//				alert(JSON.stringify(data));
				if(data){
					options = '';
					$.each(data, function(k, v){
						options += '<option value="'+v.department_id+'">'+v.name+'</option>';
					});
					$(ddiv).append('<div class="col-sm-2 dli dep'+gdid+'"><select id="'+gdid+'" class="form-control" onchange="changeRoleContent(this.value,this.id)"><option value="">请选择部门</option>'+options+'</select></div>');
				}else{
					$(ddiv).append('');
				}
			},
//			error:function(xhr){
//				
////				 alert("错误提示： " + xhr.status + " " + xhr.statusText);
////				 alert(JSON.stringify(xhr));
//			},
			dataType:'json'
		});
	}
	function che(mid){
		$('#'+mid).val($.trim($('#'+mid).val()));
	}
</script>


<include file="Public:alert" />
<include file="Public:footer" />